<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript">

  // 选择课程
  function selectCourse(id){
    if(confirm("确认要同意吗")){
      $.post("${pageContext.request.contextPath}/student?action=receive",{id:id},
              function(result){
                var result=eval('('+result+')');
                if(result.success){
                  alert("添加成功!");
                  window.location.href="${pageContext.request.contextPath}/student?action=examine";
                }else{
                  alert("不能添加！");
                }
              }
      );
    }
  }


  function studentDelete(id){
    if(confirm("确认要删除这条记录吗？")){
      $.post("${pageContext.request.contextPath}/student?action=deleteSc",{id:id},
              function(result){
                var result=eval('('+result+')');
                if(result.success){
                  alert("删除成功!");
                  window.location.href="${pageContext.request.contextPath}/student?action=examine";
                }else{
                  alert("不能删除！");
                }
              }
      );
    }
  }

</script>



<div>
  <table class="table table-hover  table-bordered table-striped" style="margin-bottom: 0px;">
    <tr>
      <th>课程名称</th>
      <th>授课老师</th>
      <th>学分</th>
      <th>选课学生</th>
    </tr>
    <c:forEach var="studentCourse" items="${courseList }" varStatus="status">
      <tr>
        <td>${status.index+1 }</td>
        <td>${studentCourse.courseName }</td>
        <td>${studentCourse.teacherName }</td>
        <td>${studentCourse.credit }</td>
        <td>${studentCourse.studentName }</td>
        <td><button type="button" class="btn btn-info btn-xs" onclick="selectCourse(${studentCourse.id })">接受</button>&nbsp;
          <button type="button" class="btn btn-danger btn-xs" onclick="studentDelete(${studentCourse.id })">拒绝</button></td>
      </tr>
    </c:forEach>
  </table>
  <nav >
    <ul class="pagination">
      ${pageCode }
    </ul>
  </nav>
</div>
